package edu.pku.sei.transformation.editor.actions;

import org.eclipse.jface.action.Action;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;

import edu.pku.sei.transformation.editor.model.execution.Model;
import edu.pku.sei.transformation.editor.views.icons.IconsProvider;

public class LoadModelAction extends Action {
	private Model model = null;
	public LoadModelAction(Model model) {
		this.model = model;
		this.setText("load model");
		this.setImageDescriptor(IconsProvider.getImageDescriptor(IconsProvider.FILE_IMPORT_ICO));
	}
	@Override
	public void run() {
		Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
		.getShell();
		FileDialog fd = new FileDialog(shell);
	//	fd.setFilterExtensions(new String[] { "*.ecore", "*.xmi", "*.xml" });
		String addr = fd.open();
		if (addr == null)
			return;
		this.model.setFile(addr);
	}
}
